﻿<UserControl x:Class="Notoric.Gui.Controls.RtfTextSectionInterior"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             DataContextChanged="UserControl_DataContextChanged"
             >
    <UserControl.Resources>
        <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="{Binding Owner.Background.Color, Mode=OneWay}" />
        <SolidColorBrush x:Key="DisabledForegroundBrush" Color="Black" />

        <SolidColorBrush x:Key="DisabledBorderBrush" Color="Transparent" />
        <SolidColorBrush x:Key="WindowBackgroundBrush" Color="White" />
        <SolidColorBrush x:Key="SolidBorderBrush" Color="Black" />

        <Style x:Key="{x:Type RichTextBox}" TargetType="{x:Type TextBoxBase}">
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="MinWidth" Value="120"/>
            <Setter Property="MinHeight" Value="20"/>
            <Setter Property="AllowDrop" Value="true"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBoxBase}">
                        <Border   
          Name="Border" 
          CornerRadius="2"   
          Padding="2" 
          Background="{StaticResource WindowBackgroundBrush}" 
          BorderBrush="{StaticResource SolidBorderBrush}" 
          BorderThickness="1" >
                            <ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}"/>
                                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}"/>
                                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <RichTextBox x:Name="PART_TextBox" LostFocus="PART_TextBox_LostFocus" SelectionChanged="PART_TextBox_SelectionChanged" 
                     GotFocus="PART_TextBox_GotFocus" AcceptsTab="True" />
    </Grid>
</UserControl>
